#include "SoundManager.h"
#include "SimpleAudioEngine.h"

using namespace CocosDenshion;

static SoundManager* pSharedSoundManager = NULL;

const char* Sound_Effect_Name[eSoundEffectID_Num] = 
{
	"correct1.mp3",		//eSoundEffectID_Correct1,
	"correct2.mp3",		//eSoundEffectID_Correct2,
	"correct3.mp3",		//eSoundEffectID_Correct3,
	"Error.mp3",		//eSoundEffectID_Error,
	"Repeat.mp3",		//eSoundEffectID_Repeat,
	"EndGame.mp3",		//eSoundEffectID_EndGame,
	"StartGame.mp3",	//eSoundEffectID_StartGame,
	"click1.mp3",		//eSoundEffectID_Click1,

};
const char* Music_Name[eMusicID_Num] = 
{
	"Main_bgm.mp3",
	"Play_bgm_long.mp3",		//eClassic_Mode_Music,
};

SoundManager& SoundManager::getInstance()
{
	static SoundManager smInstance;

	return smInstance;
}

void SoundManager::preload()
{
	SimpleAudioEngine* audioEngine = SimpleAudioEngine::sharedEngine();
	for(int i = 0; i < eSoundEffectID_Num; i++)
	{
		audioEngine->preloadEffect(Sound_Effect_Name[i]);
	}
	
// 	for(int i = 0; i < eMusicID_Num; i++)
// 	{
// 		audioEngine->preloadBackgroundMusic(Music_Name[i]);
// 	}
}

void SoundManager::unload()
{
	
}

void SoundManager::playEffect(SoundEffectID sfx)
{
	SimpleAudioEngine::sharedEngine()->playEffect(Sound_Effect_Name[sfx]);
}

void SoundManager::playMusic(MusicID musicID)
{
	SimpleAudioEngine::sharedEngine()->playBackgroundMusic(Music_Name[musicID], true);
}

void SoundManager::pauseMusic()
{
	SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}

void SoundManager::resumeMusic()
{
	SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}